
add(1, 2)
// minus(4,3)
function add(a, b) {
    return a + b
}

let minus = function (a, b) {
    return a - b
}
//给形参加上默认参数
function print(str = "Hello, world!", num = 0) {
    console.log(num)
    console.log(str);
}
//把arguments转换成数组
function bar() {
    let arr = [...arguments]
    console.log(arr)
}

var a = 1
function plus(x) {
    x++
}
plus(a)

var b = [1, 2, 3]
function insert(x) {
    x.push('新增的')
    return 1
}
insert(b)
console.log(x)
var x = 1;//上面那句话不会报错，x的声明被提升到最前，但是x的赋值还是这里。

let btns = document.querySelectorAll('.btn')
for (var i = 0; i < btns.length; i++) {

    // (function(x){
    //     btns[x].onclick = function(){console.log(btns[x].innerText)}
    // })(i)
    function foo(x) {
        btns[x].onclick = function () { console.log(btns[x].innerText) }
    }
    foo(i)
}

//闭包
function test() {
    var str = "Hello, world!";
    function print(x){
        console.log(x)
        return x
    }
    return print(str)
}
let foo = test()

function increment(n) {
	return function () {
		return n++;
	};
}
var inc = increment(5);

function inc1(){
    let n = 6
    return n++
}

